﻿#include "mainwindow.h"
#include "./ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    on_pushButtonConn_clicked();
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_pushButtonConn_clicked()
{
    connect(ui->lineEdit, &QLineEdit::textEdited, ui->label, &QLabel::setText);
    ui->pushButtonConn->setEnabled(false);      //已经关联，禁用关联按钮
    ui->pushButtonDisConn->setEnabled(true);    //已经关联，只有解除关联按钮可用
}


void MainWindow::on_pushButtonDisConn_clicked()
{
    disconnect(ui->lineEdit, &QLineEdit::textEdited, ui->label, &QLabel::setText);
    ui->pushButtonConn->setEnabled(true);      //已经关联，禁用关联按钮
    ui->pushButtonDisConn->setEnabled(false);    //已经关联，只有解除关联按钮可用
}

